package com.zzyl.controller;

import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目")
public class NursingProjectController {

    @Autowired
    NursingProjectService nursingProjectService;


    @GetMapping
    @ApiOperation(value = "分页查询")
    public ResponseResult<PageResponse<NursingProjectVo>> selectAll(@ApiParam("护理名称") String name, Integer status, Integer pageNum, Integer pageSize){
        PageResponse pageResponse = nursingProjectService.selectAll(name, status,pageNum,pageSize);
        return ResponseResult.success(pageResponse);

    }

    @PostMapping("/nursing_project")
    @ApiOperation(value = "添加护理项目")
    public ResponseResult addNursing(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.addNursing(nursingProjectDto);
        return ResponseResult.success();
    }



    @GetMapping("/nursing_project/{id}")
    @ApiOperation(value = "根据id查询护理项目")
    public ResponseResult selectById(@ApiParam("护理id") @PathVariable Long id){
        NursingProjectVo nursingProjectVo = nursingProjectService.selectById(id);
        return ResponseResult.success(nursingProjectVo);
    }


    @PutMapping("/nursing_project")
    @ApiOperation(value = "修改护理项目")
    public ResponseResult update(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.update(nursingProjectDto);
        return ResponseResult.success();
    }

    @PutMapping("/nursing_project/{id}/status/{status}")
    @ApiOperation(value = "启用禁用护理项目")
    public ResponseResult updateStatus(@ApiParam("护理id") @PathVariable Long id,@ApiParam("护理项目状态") @PathVariable Integer status){
        nursingProjectService.updateStatus(id,status);
        return ResponseResult.success();
    }

    @DeleteMapping("/nursing_project/{id}")
    @ApiOperation(value = "删除护理项目")
    public ResponseResult deleteById(@ApiParam("护理项目id") @PathVariable Long id){
        nursingProjectService.deleteById(id);
        return ResponseResult.success();
    }


    @GetMapping("/nursing_project/all")
    @ApiOperation(value = "查询所有护理项目")
    public  ResponseResult selectAllNur(){
        List<NursingProjectVo> nursingProjectVos = nursingProjectService.selectAllNur();
        return ResponseResult.success(nursingProjectVos);
    }




}


















